 //
//  SemaphoreDemo.m
//  iOSLock
//
//  Created by 崔博 on 2018/7/25.
//  Copyright © 2018年 崔博. All rights reserved.
//

#import "SemaphoreDemo.h"

@interface SemaphoreDemo ()
@property (nonatomic, strong) dispatch_semaphore_t semaphore;
@end
@implementation SemaphoreDemo

- (instancetype)init
{
    self = [super init];
    if (self) {
        // 设置银行量的初始值
        int value = 4;
       dispatch_semaphore_t semaphore = dispatch_semaphore_create(value);
    }
    return self;
}
- (void)teset
{
    // 信号量的值>0 就让信号量的值-1 然后继续执行代码
    dispatch_semaphore_wait(_semaphore, DISPATCH_TIME_FOREVER);
    // 让信号量的值加1
    dispatch_semaphore_signal(_semaphore);
}
@end
